﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter09.Code09
{
    using Chapter09.Code09;
    using Chapter09.Code06.CardLib;

    public class Demo
    {
        public static void Begin()
        {
            //01 详见 MyClass 类
            //02 详见 MyDerivedClass 类
            //03 如果方法具有返回值，就可以将其用作表达式的一部分，编译的时候有些分部方法没有实现任何代码，会完全删除代码，导致调用分部方法时出错，同样，也禁止使用out参数，导致out参数消失
            //04 
            {
                MyCopyableClass ojb1 = new MyCopyableClass();
                ojb1.ContainedInt = 5;
                MyCopyableClass ojb2 = ojb1.GetCopy();
                ojb1.ContainedInt = 9;
                Console.WriteLine(ojb2.ContainedInt);
                Console.ReadLine();
            }
            //05 
            {
                while (true)
                {
                    Deck playDeck = new Deck();
                    playDeck.Shuffle();
                    bool isFlush = false;
                    int flushHandIndex = 0;
                    for (int hand = 0; hand < 10; hand++)
                    {
                        isFlush = true;
                        Suit flushSuit = playDeck.GetCard(hand * 5).suit;
                        for (int card = 1; card < 5; card++)
                        {
                            if (playDeck.GetCard(hand * 5 + card).suit != flushSuit)
                            {
                                isFlush = false;
                            }
                        }
                        if (isFlush)
                        {
                            flushHandIndex = hand * 5;
                            break;
                        }
                    }
                    if (isFlush)
                    {
                        Console.WriteLine("Fulsh!");
                        for (int card = 0; card < 5; card++)
                        {
                            Console.WriteLine(playDeck.GetCard(flushHandIndex + card));
                        }
                        break;
                    }
                    else
                    {
                        Console.WriteLine("No flush.");
                    }
                    Console.ReadLine();
                }
            }
        }
    }
}
